#ifndef __RESULTBUFFER_H__
#define __RESULTBUFFER_H__
#include "mian_util.h"
struct Buffer {
	//for alignment result output
	uint64 saBufSize;
	uint3* cpuSA;

	//for getRefPos
	//these three pointers shoule be allocated using allocate after the alignment process
	uint32* queryId;
	uint32* offset;
	uint32* pos;
	//these two pointers are allocated
	uint32* c_queryId;
	uint32* c_queryId_len;

	void allocate(const int numSA, const int nresult) {
		queryId =  (uint32*)malloc(sizeof(int)*numSA);
		offset =  (uint32*)malloc(sizeof(int)*numSA);
		pos =  (uint32*)malloc(sizeof(int)*nresult);

		printf("Buffer::allocate done: %lu bytes.\n", (uint64)sizeof(int)*(numSA*2 + (uint64)nresult));
	}

	void release() {
		free(queryId);
		free(offset);
		free(pos);
	}
};


struct Read{
	char* readNameBuffer;
	unsigned int* readBuffer;
	uint32 numQuery;

	int textLength;
	int readNum;
	int maxReadNameLength;
	int readLength; 

	void writeMeta(FILE* resultFile) {
		fwrite(&textLength, sizeof(int), 1, resultFile);
		fwrite(&readNum, sizeof(int), 1, resultFile);
		fwrite(&maxReadNameLength, sizeof(int), 1, resultFile);
		fwrite(&readLength, sizeof(int), 1, resultFile);
	}
};
#endif
